package com.example.myapplication;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class RegisterActivity  extends Activity{
    private  EditText et_username,et_password;
    private Button bt_register;
    private String userName,password;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        et_username=findViewById(R.id.et_username);
        et_password=findViewById(R.id.et_password);
        bt_register=findViewById(R.id.bt_register);
        et_username.setOnFocusChangeListener(new View.OnFocusChangeListener(){
            @Override
           public void onFocusChange(android.view.View view, boolean b){
                if(b){

                }
            }
        });
        bt_register.setOnClickListener(new View.OnClickListener() {
            @Override

            public void onClick(View view) {
                getEditString();
                if(TextUtils.isEmpty(userName)){
                    Toast.makeText(RegisterActivity.this, "请输入用户名", Toast.LENGTH_SHORT).show();
                    return;
                }else if(TextUtils.isEmpty(password)){
                    Toast.makeText(RegisterActivity.this, "请输入密码", Toast.LENGTH_SHORT).show();
                    return;
                }else{
                    Intent it=new Intent();
                    it.setClass(RegisterActivity.this,LoginActivity.class);
                    RegisterActivity.this.startActivity(it);
                }

            }
        });

    }
    private void getEditString(){
        userName=et_username.getText().toString().trim();
        password=et_password.getText().toString().trim();
    }

}
